package com.ruoyi.project.system.mapper;

import java.util.List;

import com.ruoyi.project.system.domain.Member;
import com.ruoyi.project.system.domain.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.security.core.parameters.P;

/**
 * [会员]Mapper接口
 * 
 * @author ruoyi
 * @date 2020-10-07
 */
@Mapper
public interface MemberMapper 
{
    /**
     * 查询[会员]
     * 
     * @param id [会员]ID
     * @return [会员]
     */
    public Member selectMemberById(Integer id);

    /**
     * 查询[会员]列表
     * 
     * @param member [会员]
     * @return [会员]集合
     */
    public List<Member> selectMemberList(Member member);

    /**
     * 新增[会员]
     * 
     * @param member [会员]
     * @return 结果
     */
    public int insertMember(Member member);

    /**
     * 修改[会员]
     * 
     * @param member [会员]
     * @return 结果
     */
    public int updateMember(Member member);

    /**
     * 删除[会员]
     * 
     * @param id [会员]ID
     * @return 结果
     */
    public int deleteMemberById(Integer id);

    /**
     * 批量删除[会员]
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteMemberByIds(Integer[] ids);

    @Select("select user_name as userName,pw from sys_user where user_id = (\n" +
            "select COALESCE(s.user_id, 0) + COALESCE(c.user_id, 0) as user_id\n" +
            "from \"member\" m \n" +
            "left join student s on m.id = s.member_id\n" +
            "left join college_staff c on m.id = c.member_id\n" +
            "where m.wx_open_id = #{openid})")
    SysUser getUserByOpenid(String openid);


    Member getByOpenid(@Param("id")String openid);

    List<Member> setMemberList(@Param("code") String username,@Param("pwd")String pwd);

    @Update("update member set wx_open_id=null where  id=#{id}")
    Integer updateMemberWxOpenId(@Param("id") int intValue);
}
